package com.sinba.common.system.action;

import org.springframework.beans.factory.annotation.Autowired;

import com.opensymphony.xwork2.ActionSupport;
import com.sinba.common.dto.PageDTO;
import com.sinba.common.system.dto.IMessageDTO;
import com.sinba.common.system.service.IIMessageService;

@SuppressWarnings("serial")
public class IMessageAction extends ActionSupport{
	
	@Autowired
	private IIMessageService imessageService;
	private PageDTO pageDTO = new PageDTO();
	private IMessageDTO imessageDto = new IMessageDTO();
	private Long[] ids;
    private int page = 1;
    private int rows = 10;
    private String sord;
    private String sidx;
	public PageDTO getPageDTO() {
		return pageDTO;
	}
	public void setPageDTO(PageDTO pageDTO) {
		this.pageDTO = pageDTO;
	}
	public IMessageDTO getImessageDto() {
		return imessageDto;
	}
	public void setImessageDto(IMessageDTO imessageDto) {
		this.imessageDto = imessageDto;
	}
	public Long[] getIds() {
		return ids;
	}
	public void setIds(Long[] ids) {
		this.ids = ids;
	}
	public int getPage() {
		return page;
	}
	public void setPage(int page) {
		this.page = page;
	}
	public int getRows() {
		return rows;
	}
	public void setRows(int rows) {
		this.rows = rows;
	}
	public String getSord() {
		return sord;
	}
	public void setSord(String sord) {
		this.sord = sord;
	}
	public String getSidx() {
		return sidx;
	}
	public void setSidx(String sidx) {
		this.sidx = sidx;
	}
    
	public String findPageIMessage(){
		int start = ( page - 1 ) * rows;
		imessageDto.setStart( start );
		imessageDto.setLimit( rows );
		pageDTO = imessageService.findPageIMessage(imessageDto, sord, sidx);
		if ( pageDTO != null ){
            pageDTO.setPage( page );
            pageDTO.setRows( rows );
        }
		return SUCCESS;
	}
	
	public String sendMessage(){
		imessageService.sendMessage(imessageDto);
		return "imessage";
	}
	
	public String reply(){
		imessageService.reply(imessageDto);
		return SUCCESS;
	}
	
	public String deletes(){
		imessageService.deletes(ids);
		return SUCCESS;
	}
	
	public String changeStatus(){
		imessageService.changeStatus(imessageDto);
		return SUCCESS;
	}
	
}
